package com.scn.base.dao.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.scn.base.dao.SysRoleDao;
import com.scn.base.domain.RoleVO;
import com.scn.base.page.PageVO;

public class SysRoleDaoImpl extends SqlMapClientDaoSupport implements SysRoleDao{

	public int selectRoleCount() {
		
		return (Integer)getSqlMapClientTemplate().queryForObject("selectRoleCount");
	}

	public void insertSysRole(RoleVO role) {
		getSqlMapClientTemplate().insert("insertSysRole",role);
	}
	
	//权限组设置
	public void insertSysRoles(RoleVO role) {
		getSqlMapClientTemplate().insert("insertSysRoles",role);
	}
	
	//获取自动增长
	public long getSeq(){
		return (Long)getSqlMapClientTemplate().queryForObject("selectRoleSeq");
	}

	public List selectRoleList(PageVO page) {
		List list = new ArrayList();
		list = getSqlMapClientTemplate().queryForList("selectRoleList",(page.getCurPage()-1)*page.getPageSize(), page.getPageSize());
		if(list != null && list.size() > 0){
			return list;
		}else{
		    return null;
		}
	}

	@SuppressWarnings("unchecked")
	public List selectRoleList() {
		List list = new ArrayList();
		list = getSqlMapClientTemplate().queryForList("selectRoleList");
		if(list != null && list.size() > 0){
			return list;
		}else{
		    return null;
		}
	}

	public void deleteSysRoleById(int srid) {
	   getSqlMapClientTemplate().delete("deleteSysRoleById",srid);
	}

	public RoleVO selectRoleById(int srid) {
		return (RoleVO)getSqlMapClientTemplate().queryForObject("selectRoleById",srid);
	}

	public void updateSysRole(Map sysRoleMap) {
		getSqlMapClientTemplate().update("updateSysRole",sysRoleMap);
	}
	
	

}
